publicstaticvoidsolve() { intn= io.nextInt(), k = io.nextInt(), x = io.nextInt(); if (n < k || x < k - 1) io.println(-1); else io.println((k - 1) * k / 2 + (n - k) * (x == k ? k - 1 : x)); }
publicstaticvoidsolve() { intn= io.nextInt(), m = io.nextInt(); inta=0; for (inti=0; i < n; i++) { a ^= io.nextInt(); } intb=0; for (inti=0; i < m; i++) { b |= io.nextInt(); } intmin= a, max = a; if (n % 2 == 0) { min = a ^ (a & b); } else { max = a | b; } io.println(min + " " + max); }
voidsolve(){ int n; cin >> n; vector<int> c(n); for (int i = 0; i < n; i++) { cin >> c[i]; } int k; cin >> k; for (int i = n - 2; i >= 0; i--) { c[i] = min(c[i], c[i + 1]); } int m = k; for (int i = 0; i < n; i++) { int x = i == 0 ? c[i] : c[i] - c[i - 1]; if (x != 0) m = min(m, k / x); k -= x * m; cout << m << " \n"[i == n - 1]; } }